package com.ld.admin.util.daliySentence.impl;

import org.apache.commons.lang.math.RandomUtils;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import com.ld.admin.util.daliySentence.DaliySentence;
import com.ld.shieldsb.common.core.util.JsoupUtil;

/**
 * 
 * 句子控
 * 
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2020年1月8日 下午2:12:23
 *
 */
public class DaliySentenceJuzikong implements DaliySentence {
    public static final String URL_ONE = "https://www.juzikong.com/discovery/hot";

    @Override
    public String getSentence() {
        String content = null;
        Document document = JsoupUtil.getRemoteURLDocument(URL_ONE, null);
        if (document != null) {
            Elements contentCs = document.select("div.body_2xJQU");
            int random = RandomUtils.nextInt(20) % contentCs.size();
            Element contentEle = contentCs.get(random); // 内容
            content = contentEle.text() + "【来自<a href='https://www.juzikong.com/discovery/hot' target='_blank'>「句子控」</a>】";
        }
        return content;
    }

}
